package com.kylin.common.weixin.exception;

import com.kylin.common.core.beans.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.Serializable;

/**
 * 异常处理器
 *
 * @author Mark sunlightcs@gmail.com
 */
@Slf4j
@RestControllerAdvice
//需要比la-common-core中的拦截要优先拦截
@Order(-1)
public class WexinExceptionHandlerAdvice {

	/**
	 * 微信接口异常处理
	 */
	@ExceptionHandler(WechatException.class)
	public ResultBean<Serializable> handleServiceException(WechatException e){
		log.error(e.getMessage(), e);
		return new ResultBean<>(e.getCode(),e.getMessage());
	}

}
